/******************************************/
/******************************************/
/****  JS Document                     ****/
/****  by type/code                    ****/
/****  andrew@typeslashcode.com        ****/
/******************************************/
/******************************************/

(function(tc) {
	tc.jQ.fn.portfolioSite = function(options){
		var $ps = this, _o = {};
		
		_o = jQuery.extend({
			content:""
		},options);
		
		function _initialize(){
			tc.util.log("portfolioSite._initialize",'info');
			_setup_components();
			_setup_events();
			return $ps;
		}
		
		function _setup_components(){
			tc.util.log("portfolioSite._setup_components",'info');
			$ps.find('.portfolioItem').each(function(i,j){
				tc.jQ(j).portfolioItem(_o);
			});
			
		}
		
		function _setup_events(){
			tc.util.log("portfolioSite._setup_events",'info');
			$ps.find('#aboutButton').bind('click',_aboutButtonClickHandler)
			$ps.find('#contactButton').bind('click',_contactButtonClickHandler)
		}
		
		function _aboutButtonClickHandler(e,d){
			tc.util.log("portfolioSite._aboutButtonClickHandler",'info');
			e.preventDefault();
			tc.jQ.scrollTo('#aboutSection img,#aboutSection p',1200,{ easing:'easeInOutCubic' });
		}
		
		function _contactButtonClickHandler(e,d){
			tc.util.log("portfolioSite._contactButtonClickHandler",'info');
			e.preventDefault();
			tc.jQ.scrollTo('#contactSection img,#aboutSection p',1200,{ easing:'easeInOutCubic' });
		}
		
		return _initialize();
	}
	
	tc.jQ.fn.portfolioItem = function(options){
		var $pi = this, _o = {};
		
		_o = jQuery.extend({
			content:""
		},options);
		
		function _initialize(){
			tc.util.log("portfolioItem._initialize",'info');
			_setup_components();
			_setup_events();
			$pi.children('.text').hide();
			return $pi;
		}
		
		function _setup_components(){
			tc.util.log("portfolioItem._setup_components",'info');
		}
		
		function _setup_events(){
			tc.util.log("portfolioItem._setup_events",'info');
			$pi.find('img').bind('mouseenter',_portfolioItemMouseenterHandler);
		}
		
		function _portfolioItemMouseenterHandler(e,d){
			tc.util.log("portfolioItem._portfolioItemMouseenterHandler",'info');
			var _tp = tc.jQ(e.target).position(),
				_tw = tc.jQ(e.target).width(),
				_th = tc.jQ(e.target).height();
			$pi.children('.text')
				.css('top',_tp['top'])
				.css('left',_tp['left'])
				.css('width',_tw)
				.css('height',_th)
				.show();
			$pi.children('.images').children('img')
				.css('borderBottom',"1px solid black")
				.css('marginBottom','14px');
			$pi.children('.text').one('mouseleave',_portfolioItemMouseleaveHandler);
		}
		
		function _portfolioItemMouseleaveHandler(e,d){
			tc.util.log("portfolioItem._portfolioItemMouseleaveHandler",'info');
			$pi.children('.images').children('img')
				.css('borderBottom',"none")
				.css('marginBottom','15px');
			$pi.children('.text').hide();
			
		}
		
		return _initialize();
	}
	
})(tc);